<template>
  <div>
    <div class="bread">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '#' }" style="font-size: 20px;">首页</el-breadcrumb-item>
        <el-breadcrumb-item style="font-size: 20px;">人员管理</el-breadcrumb-item>
        <el-breadcrumb-item style="font-size: 20px;">添加管理员</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div style="width: 400px; margin-top: 50px;">
      <el-form :model="accountForm" :rules="rules" ref="accountForm" label-width="100px" class="demo-ruleForm">
        <el-form-item label="账号名" prop="accountName">
          <el-input v-model="accountForm.accountName"></el-input>
        </el-form-item>
        <el-form-item label="昵称" prop="accountNickname">
          <el-input v-model="accountForm.accountNickname"></el-input>
        </el-form-item>
        <el-form-item label="电话" prop="accountPhone">
          <el-input v-model="accountForm.accountPhone"></el-input>
        </el-form-item>
        <el-form-item label="密码" prop="accountPass">
          <el-input v-model="accountForm.accountPass"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm('accountForm')">立即新增</el-button>
          <el-button @click="resetForm('accountForm')">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        accountForm: {
          accountName: '',
          accountNickname: '',
          accountPhone: '',
          accountPass: '',
          aaaa:null
        },
        rules: {
          accountName: [{
            required: true,
            message: '请输入账号',
            trigger: 'blur'
          }],
          accountNickname: [{
            required: true,
            message: '请输入昵称',
            trigger: 'blur'
          }],
          accountPhone: [{
            required: true,
            message: '请输入电话',
            trigger: 'blur'
          }],
          accountPass: [{
            required: true,
            message: '请输入密码',
            trigger: 'blur'
          }]
        }
      };
    },
    methods: {
      submitForm(accountForm) {
        this.$refs[accountForm].validate((valid) => {
          if (valid) { //注册操作
            this.$http.post("/account/admin/addAccount", this.accountForm).then(resp => {
              if (resp.data.code == 200) {
                this.resetForm(accountForm);
                alert(resp.data.message)
              } else {
                alert(resp.data.message)
              }
            })
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(accountForm) {
        this.$refs[accountForm].resetFields();
      }
    },
    created() {

    }
  }
</script>

<style scoped>
  .bread {
    margin-top: 50px;
    margin-left: 50px;
  }
  /* .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409eff;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 80px;
    height: 80px;
    text-align: center;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  } */
</style>

<style>
  .el-input__inner::placeholder {
    color: #31E5F5;
  }
</style>